//
//  UIBarButtonItem+Extension.swift
//  HMWeibo08
//
//  Created by 唐万超 on 15/8/7.
//  Copyright © 2015年 唐万超. All rights reserved.
//

import UIKit

extension UIBarButtonItem {

    convenience init(imageName: String, target: AnyObject?, action: String?) {
        
        let btn = UIButton()
        btn.setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        btn.setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        btn.sizeToFit()
        
        if let actionName = action {
            btn.addTarget(target, action: Selector(actionName), forControlEvents: UIControlEvents.TouchUpInside)
            
        }
        
        self.init(customView:btn)
        
    }
    
}
